package com.cti.ftpservice.vo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;

import com.cti.ftpservice.ftp.DateHelper;


/**
 * ONIX书目数据检索类
 * 
 * @author ljk
 *
 */
public class OnixBookInfoQueryVo {
	/**
	 * ISBN
	 */
	private List<String> isbns = new ArrayList<String>();
	/**
	 * 出版社
	 */
	private String publisherName;
	/**
	 * 出版年 存在多个用;隔开
	 */
	private String[] pubYears;
	/**
	 * 更新时间 开始时间 结束时间用#隔开
	 */
	private String updateValues;
	
	private Map<String, Object> mapParams=new HashMap<String,Object>();
	/**
	 * 返回传入的参数
	 * @return
	 */
	public Map<String, Object> GetMapParama(){
		return mapParams;
	}
	/**
	 * 返回传入的查询语句
	 * @return
	 */
	public String getHql(){
		mapParams.clear();
		String hql="";
		if(this.isbns!=null && this.isbns.size()>0){
			hql+=" and t.isbn in (:isbn)";
			mapParams.put("isbn",this.isbns.toArray(new String[this.isbns.size()]));
		}
		if(this.pubYears!=null &&this.pubYears.length>0){
			hql+=" and t.publishYear in (:pubYear)";
			mapParams.put("pubYear",this.pubYears);
		}
		if(!StringUtils.isBlank(this.updateValues) && this.updateValues.contains("#")){
		    String[] updateDate=this.updateValues.split("#");
		    if(!StringUtils.isBlank(updateDate[0]) && !StringUtils.isBlank(updateDate[1])){
		    	hql+=" and t.updateDate  between :startDate and :endDate";
		    	mapParams.put("startDate",DateHelper.stringToDate(updateDate[0],"yyyy-MM-dd hh:mm:ss"));
		    	mapParams.put("endDate",DateHelper.stringToDate(updateDate[1],"yyyy-MM-dd hh:mm:ss"));
		    }
		}
		if(!StringUtils.isBlank(this.publisherName)){
			hql+=" and t.publisherName=:publisherName";
			mapParams.put("publisherName",this.publisherName);
		}
		return 	hql;
	}

	public List<String> getIsbns() {
		return isbns;
	}

	public void setIsbns(List<String> isbns) {
		this.isbns = isbns;
	}

	public String getPublisherName() {
		return publisherName;
	}

	public void setPublisherName(String publisherName) {
		this.publisherName = publisherName;
	}

	public String[] getPubYears() {
		return pubYears;
	}

	public void setPubYears(String[] pubYears) {
		this.pubYears = pubYears;
	}

	public String getUpdateValues() {
		return updateValues;
	}

	public void setUpdateValues(String updateValues) {
		this.updateValues = updateValues;
	}

}
